<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge" >
  <title>for循环的执行顺序 | 前端.林姐姐</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="for循环的执行顺序用如下表达式：
for(expression1;expression2;expression3)
{   
          expression4;
}

执行的顺序应该是：
1）第一次循环，即初始化循环。首先执行表达式expression1（一般为初始化语句）；再执行expression2（一般为条件判断语句），判断expression1是否符合expression2的条">
<meta property="og:type" content="article">
<meta property="og:title" content="for循环的执行顺序">
<meta property="og:url" content="http://yoursite.com/2016/02/02/for循环的执行顺序/index.html">
<meta property="og:site_name" content="前端.林姐姐">
<meta property="og:description" content="for循环的执行顺序用如下表达式：
for(expression1;expression2;expression3)
{   
          expression4;
}

执行的顺序应该是：
1）第一次循环，即初始化循环。首先执行表达式expression1（一般为初始化语句）；再执行expression2（一般为条件判断语句），判断expression1是否符合expression2的条">
<meta property="og:updated_time" content="2016-02-02T11:38:59.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="for循环的执行顺序">
<meta name="twitter:description" content="for循环的执行顺序用如下表达式：
for(expression1;expression2;expression3)
{   
          expression4;
}

执行的顺序应该是：
1）第一次循环，即初始化循环。首先执行表达式expression1（一般为初始化语句）；再执行expression2（一般为条件判断语句），判断expression1是否符合expression2的条">
  
    <link rel="alternative" href="/atom.xml" title="前端.林姐姐" type="application/atom+xml">
  
  
    <link rel="icon" href="img/linjie.jpg">
  
  <link rel="stylesheet" href="/css/style.css" type="text/css">
</head>

<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
	<header id="header" class="inner">
		<a href="/" class="profilepic">
			
			<img lazy-src="undefined" class="js-avatar">
			
		</a>

		<hgroup>
		  <h1 class="header-author"><a href="/">林姐姐</a></h1>
		</hgroup>

		
		<p class="header-subtitle">让未来的你的感谢现在的自己！</p>
		

		
			<div class="switch-btn">
				<div class="icon">
					<div class="icon-ctn">
						<div class="icon-wrap icon-house" data-idx="0">
							<div class="birdhouse"></div>
							<div class="birdhouse_holes"></div>
						</div>
						<div class="icon-wrap icon-ribbon hide" data-idx="1">
							<div class="ribbon"></div>
						</div>
						
						<div class="icon-wrap icon-link hide" data-idx="2">
							<div class="loopback_l"></div>
							<div class="loopback_r"></div>
						</div>
						
						
						<div class="icon-wrap icon-me hide" data-idx="3">
							<div class="user"></div>
							<div class="shoulder"></div>
						</div>
						
					</div>
					
				</div>
				<div class="tips-box hide">
					<div class="tips-arrow"></div>
					<ul class="tips-inner">
						<li>菜单</li>
						<li>標籤</li>
						
						<li>友情链接</li>
						
						
						<li>關於</li>
						
					</ul>
				</div>
			</div>
		

		<div class="switch-area">
			<div class="switch-wrap">
				<section class="switch-part switch-part1">
					<nav class="header-menu">
						<ul>
						
							<li><a href="/">主页</a></li>
				        
							<li><a href="/archives">所有文章</a></li>
				        
							<li><a href="/categories/学习笔记/">学习笔记</a></li>
				        
							<li><a href="/categories/技术摘录/">技术摘录</a></li>
				        
						</ul>
					</nav>
					<nav class="header-nav">
						<div class="social">
							
								<a class="github" target="_blank" href="https://github.com/linjieFE" title="github">github</a>
					        
								<a class="mail" target="_blank" href="mailto:solocode@163.com" title="mail">mail</a>
					        
						</div>
					</nav>
				</section>
				
				
				<section class="switch-part switch-part2">
					<div class="widget tagcloud" id="js-tagcloud">
						<a href="/tags/gulp/" style="font-size: 10px;">gulp</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a> <a href="/tags/javascript/" style="font-size: 10px;">javascript</a> <a href="/tags/mac技巧/" style="font-size: 13.33px;">mac技巧</a> <a href="/tags/react/" style="font-size: 10px;">react</a> <a href="/tags/react-native/" style="font-size: 10px;">react-native</a> <a href="/tags/vim/" style="font-size: 10px;">vim</a> <a href="/tags/前题面试题/" style="font-size: 10px;">前题面试题</a> <a href="/tags/学习笔记/" style="font-size: 20px;">学习笔记</a> <a href="/tags/终端/" style="font-size: 10px;">终端</a> <a href="/tags/随笔/" style="font-size: 16.67px;">随笔</a>
					</div>
				</section>
				
				
				
				<section class="switch-part switch-part3">
					<div id="js-friends">
					
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.ruanyifeng.com/home.html">阮一峰ES6</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://nodeapi.ucdok.com/api/">NodeJS在线文档</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://jquery.cuishifeng.cn">jquery在线文档</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.w3school.com.cn/js/">javascript手册</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.phpstudy.net/css3/">css3在线手册</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.css6.com">凯哥的博客</a>
			        
			        </div>
				</section>
				

				
				
				<section class="switch-part switch-part4">
				
					<div id="js-aboutme">80s，来自祖国最东端乌苏里江畔。爱好运动和音乐，希望在这里可以跟一样爱好前端的朋友共同进步！</div>
				</section>
				
			</div>
		</div>
	</header>				
</div>

    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
  	<div class="overlay">
  		<div class="slider-trigger"></div>
  		<h1 class="header-author js-mobile-header hide">林姐姐</h1>
  	</div>
	<div class="intrude-less">
		<header id="header" class="inner">
			<div class="profilepic">
			
				<img lazy-src="undefined" class="js-avatar">
			
			</div>
			<hgroup>
			  <h1 class="header-author">林姐姐</h1>
			</hgroup>
			
			<p class="header-subtitle">让未来的你的感谢现在的自己！</p>
			
			<nav class="header-menu">
				<ul>
				
					<li><a href="/">主页</a></li>
		        
					<li><a href="/archives">所有文章</a></li>
		        
					<li><a href="/categories/学习笔记/">学习笔记</a></li>
		        
					<li><a href="/categories/技术摘录/">技术摘录</a></li>
		        
		        <div class="clearfix"></div>
				</ul>
			</nav>
			<nav class="header-nav">
				<div class="social">
					
						<a class="github" target="_blank" href="https://github.com/linjieFE" title="github">github</a>
			        
						<a class="mail" target="_blank" href="mailto:solocode@163.com" title="mail">mail</a>
			        
				</div>
			</nav>
		</header>				
	</div>
</nav>

      <div class="body-wrap"><article id="post-for循环的执行顺序" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2016/02/02/for循环的执行顺序/" class="article-date">
  	<time datetime="2016-02-02T07:38:29.000Z" itemprop="datePublished">2016-02-02</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      for循环的执行顺序
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
	<div class="article-tag tagcloud">
		<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/随笔/">随笔</a></li></ul>
	</div>

        
	<div class="article-category tagcloud">
	<a class="article-category-link" href="/categories/知识点滴/">知识点滴</a>
	</div>


        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>for循环的执行顺序用如下表达式：</p>
<pre><code class="JavaScript"><span class="keyword">for</span>(expression1;expression2;expression3)
{   
          expression4;
}
</code></pre>
<pre><code>执行的顺序应该是：
</code></pre><h2 id="1_uFF09_u7B2C_u4E00_u6B21_u5FAA_u73AF_uFF0C_u5373_u521D_u59CB_u5316_u5FAA_u73AF_u3002"><a href="#1_uFF09_u7B2C_u4E00_u6B21_u5FAA_u73AF_uFF0C_u5373_u521D_u59CB_u5316_u5FAA_u73AF_u3002" class="headerlink" title="1）第一次循环，即初始化循环。"></a>1）第一次循环，即初始化循环。</h2><pre><code>首先执行表达式expression1（一般为初始化语句）；再执行expression2（一般为条件判断语句），判断expression1是否符合expression2的条件；如果符合，则执行expression4，否则，停止执行；最后执行expression3。
</code></pre><h2 id="2_uFF09_u7B2CN_uFF08N_26gt_3B_3D2_uFF09_u6B21_u5FAA_u73AF"><a href="#2_uFF09_u7B2CN_uFF08N_26gt_3B_3D2_uFF09_u6B21_u5FAA_u73AF" class="headerlink" title="2）第N（N&gt;=2）次循环"></a>2）第N（N&gt;=2）次循环</h2><pre><code>首先执行expression2，判断在expression3是否符合在expression2要求；如果符合，则继续执行在expression4，否则，停止执行。最后执行在expression3。如此往复，直至expression3不满足在expression2条件是为止。
</code></pre><h2 id="u603B_u7ED3_uFF1A"><a href="#u603B_u7ED3_uFF1A" class="headerlink" title="总结："></a>总结：</h2><pre><code>总的来说，执行的顺序是一致的。先条件判断（expression2），再函数体执行（expression4），最后for执行（expression3）。往复......区别在于，条件判断的对象。第一次判断时，对象为初始化语句（expression1），后续的判断对象为执行后的结果（expression3）。
</code></pre>
      
    </div>
    
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2016/07/12/gulp学习笔记/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption"><</strong>
      <div class="article-nav-title">
        
          gulp学习笔记
        
      </div>
    </a>
  
  
    <a href="/2016/02/01/Javascript-严格模式/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">Javascript 严格模式</div>
      <strong class="article-nav-caption">></strong>
    </a>
  
</nav>

  
</article>


<div class="share_jia">
	<!-- JiaThis Button BEGIN -->
	<div class="jiathis_style">
		<span class="jiathis_txt">分享到: &nbsp; </span>
		<a class="jiathis_button_facebook"></a> 
    <a class="jiathis_button_twitter"></a>
    <a class="jiathis_button_plus"></a> 
    <a class="jiathis_button_tsina"></a>
		<a class="jiathis_button_cqq"></a>
		<a class="jiathis_button_douban"></a>
		<a class="jiathis_button_weixin"></a>
		<a class="jiathis_button_tumblr"></a>
    <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
	</div>
	<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=1405949716054953" charset="utf-8"></script>
	<!-- JiaThis Button END -->
</div>






<div class="duoshuo">
	<!-- 多说评论框 start -->
	<div class="ds-thread" data-thread-key="for循环的执行顺序" data-title="for循环的执行顺序" data-url="http://yoursite.com/2016/02/02/for循环的执行顺序/"></div>
	<!-- 多说评论框 end -->
	<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
	<script type="text/javascript">
	var duoshuoQuery = {short_name:"true"};
	(function() {
		var ds = document.createElement('script');
		ds.type = 'text/javascript';ds.async = true;
		ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
		ds.charset = 'UTF-8';
		(document.getElementsByTagName('head')[0] 
		 || document.getElementsByTagName('body')[0]).appendChild(ds);
	})();
	</script>
	<!-- 多说公共JS代码 end -->
</div>




</div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info">
    	<div class="footer-left">
    		&copy; 2016 林姐姐
    	</div>
      	<div class="footer-right">
      		<a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/litten/hexo-theme-yilia" target="_blank">Yilia</a> by Litten
      	</div>
    </div>
  </div>
</footer>
    </div>
    
  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css">


<script>
	var yiliaConfig = {
		fancybox: true,
		mathjax: true,
		animate: true,
		isHome: false,
		isPost: true,
		isArchive: false,
		isTag: false,
		isCategory: false,
		open_in_new: false
	}
</script>
<script src="http://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/js/main.js" type="text/javascript"></script>






<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


  </div>
</body>
</html>